package com.example.service.impl;

import com.example.mapper.DepartmentMapper;
import com.example.model.Department;
import com.example.service.DepartmentService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@RequiredArgsConstructor
@Service
public class DepartmentServiceImpl implements DepartmentService {
    private final DepartmentMapper departmentMapper;
    @Override
    public String getNameById(int departmentId) {
        return departmentMapper.getNameById(departmentId);
    }

    @Override
    public List<Department> getDepartmentList() {
        return departmentMapper.getDepartmentList();
    }

    @Override
    public Department getDepartmentById(Integer id) {
        if(id==null)
        {
            return null;
        }
        return departmentMapper.getDepartmentById(id);
    }

    @Override
    public List<Department> getTop5Departments() {
        return departmentMapper.getTop5Departments();
    }

    @Override
    public List<Department> getDepartments() {
        return departmentMapper.getDepartments();
    }

    @Override
    public void deleteDepartmentById(int id) {
        departmentMapper.deleteDepartmentById(id);
    }

    @Override
    public void updateDepartment(Department department) {
        departmentMapper.updateDepartment(department);
    }

    @Override
    public void insertDepartment(Department department) {
        departmentMapper.insertDepartment(department);
    }
}
